MeetingNoticeGrid = function() {

    var orgSortStore = new Ext.data.Store({
        proxy: new Ext.data.ScriptTagProxy({url: '../dataDictionary/getDictionary.action?tableName=ORGSORT' }),
        fields: ['value', 'label'],
        reader: new Ext.data.ArrayReader({}, [{name: 'value', type: 'string'},{name: 'label', type: 'string'}]),
        remoteSort: false
    });
    orgSortStore.load();
    function formatOrgSort(value) {
        var bv = '';
        for (var i = 0; i < orgSortStore.getCount(); i++) {
            if (orgSortStore.getAt(i).data['value'] == value) {
                bv = orgSortStore.getAt(i).data['label'];
                break;
            }
        }
        return  bv;
    }

    var columns = new Ext.grid.LockingColumnModel([
        {
            id: 'code',
            header: "编号",
            dataIndex: 'code',
            width: 100,
            align:'center',
            sortable: true,
            locked:true,
            css: 'white-space:normal;border:#eee solid;border-width:0 0 0 1;'
        },
        {
            id: 'title',
            header: "预警或提醒名称",
            dataIndex: 'title',
            width: 300,
            align:'center',
            sortable: true,
            locked:true,
            renderer:function (value) {
                return  '<div align=left>' + value + '</div>';
            },
            css: 'white-space:normal;border:#eee solid;border-width:0 0 0 1;'
        },    {
            id: 'mtype',
            header: "类型",
            dataIndex: 'mtype',
            width: 50,
            align:'center',
            sortable: true,
            renderer:function(value) {
                if (value == '1')
                    return '预警';
                else
                    return '提醒';
            },
            locked:false,
            css: 'white-space:normal;border:#eee solid;border-width:0 0 0 1;'
        },    {
            id: 'startingTime',
            header: "开始日期",
            dataIndex: 'startingTime',
            width:100,
            align:'center',
            sortable: true,
            css: 'white-space:normal;border:#eee solid;border-width:0 0 0 1;'
        },   {
            id: 'endTime',
            header: "结束日期",
            dataIndex: 'endTime',
            width:100,
            align:'center',
            sortable: true,
            css: 'white-space:normal;border:#eee solid;border-width:0 0 0 1;'
        },{
            id: 'orgType',
            header: "发布部门",
            align:'center',
            dataIndex: 'orgType',
            width: 100,
            editable:false,
            sortable: true,
            renderer:formatOrgSort,
            css: 'white-space:normal;border:#eee solid;border-width:0 0 0 1;'
        },{
            id: 'orgName',
            header: "发布单位",
            align:'center',
            dataIndex: 'orgName',
            width: 200,
            editable:false,
            sortable: true,
            renderer:function (value) {
                return '<div align=left>' + value + '</div>'
            },
            css: 'white-space:normal;border:#eee solid;border-width:0 0 0 1;'
        }, {
            id: 'perName',
            header: "发布人",
            align:'center',
            dataIndex: 'perName',
            width: 80,
            editable:false,
            sortable: true,
            css: 'white-space:normal;border:#eee solid;border-width:0 0 0 1;'
        }  , {
            id: 'inputTime',
            header: "发布时间",
            align:'center',
            dataIndex: 'inputTime',
            width: 100,
            editable:false,
            sortable: true,
            css: 'white-space:normal;border:#eee solid;border-width:0 0 0 1;'
        }
    ]);

    var refButtonN = new Ext.Toolbar.Button({
        icon    : "../ext/examples/shared/icons/fam/connect.png",
        id      : 'refButtonN',
        cls: 'x-btn-text-icon',
        text    : '启动实时更新',
        handler : function(){
            if (meetingNoticeGridAutoRef==false) {
                meetingNoticeGridAutoRef = true;
                refButtonN.setText('停止实时更新');
            } else {
                meetingNoticeGridAutoRef = false; 
                refButtonN.setText('启动实时更新');
            }
        }
    });
    var showMeetingNoticewin;
    MeetingNoticeGrid.superclass.constructor.call(this, {
        store: new Ext.data.Store({
            proxy: new Ext.data.ScriptTagProxy({
                url: '../meetingNotice/buildJSONString4Default.action'
            }),
            reader: new Ext.data.JsonReader({
                root: 'results',
                totalProperty: 'total',
                id: 'noticeId'
            }, [
                {name: 'noticeId', mapping: 'noticeId'},
                {name: 'code', mapping: 'code'},
                {name: 'title', mapping: 'title'},
                {name: 'content', mapping: 'content'},
                {name: 'startingTime', mapping: 'startingTime'},
                {name: 'endTime', mapping: 'endTime'},
                {name: 'orgType', mapping: 'orgType'},
                {name: 'gbcode', mapping: 'gbcode'},
                {name: 'orgId', mapping: 'orgId'},
                {name: 'orgName', mapping: 'orgName'},
                {name: 'perId', mapping: 'perId'},
                {name: 'perName', mapping: 'perName'},
                {name: 'inputTime', mapping: 'inputTime'},
                    {name: 'mtype', mapping: 'mtype'}
            ]),
            remoteSort: true
        }),
        cm: columns,
        height:(document.body.offsetHeight - 160) / 2,
        bodyStyle:'width:100%;',
        tbar:[refButtonN],
        listeners: {
            'rowdblclick':{ fn:function() {
                if (showMeetingNoticewin != null) {
                    showMeetingNoticewin.destroy(true);
                    showMeetingNoticewin = null;
                }
                var selected = this.getSelectionModel().getSelections();
                var selectedCount = selected.length;
                var record = selected[0]
                var id = record.id;
                if (!showMeetingNoticewin) {
                    showMeetingNoticewin = new Ext.Window({
                        title: '预警信息',
                        id:'showMeetingNoticewin',
                        closable: true,
                        closeAction : 'hide',
                        collapsible:true,
                        resizable:true,
                        width: 500,
                        height:400,
                        layout: 'fit',
                        plain:true,
                        bodyStyle:'padding:5px;',
                        maximizable : false,
                        buttonAlign:'center',
                        items:[{
                            title: '<div align=center>' + record.get('title') + '</div>',
                            html: '<p><b>开始日期：</b>' + record.get('startingTime') +
                                  '</p><p><b>结束日期：</b>' + record.get('endTime') +
                                  '</p><p><b>预警内容：</b>' + record.get('content') +
                                  '</p><p><b>发布人：</b>' + record.get('perName') +
                                  '</p><p><b>发布时间：</b>' + record.get('inputTime') +
                                  '</p>'
                        } ],
                        buttons: [ {
                            handler: function() {
                                showMeetingNoticewin.hide();
                            },
                            text: '关闭'
                        }
                        ]
                    });
                }
                showMeetingNoticewin.show();
            }}
        }
    });

}

Ext.extend(MeetingNoticeGrid, Ext.grid.GridPanel);
  